﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Composition;
using ExtendPropertyLib.WPF;
using ExtendPropertyLib;
using ExORMDesginer.Helper;
using ExtendPropertyLib.WPF.Helper;
using MaxZhang.EasyEntities.Persistence.Provider;


namespace ExORMDesginer.UserControls
{
    public class SQLServerDialogViewModel : ViewModelBase<SQLServerDialogInfo>
    {
        [Import(typeof(IWindowManager))]
        private IWindowManager WindowManager { set; get; }

   

        #region Method
        public void ConnectionTest()
        {
            try
            {
                if (Model.IsValid)
                {
                    Model.Connect();
                    WindowManager.ShowMessage("连接成功!");
                }

                
            }
            catch (Exception ex)
            {
                WindowManager.ShowMessage(ex.Message);
            }
        }


        public void Save()
        {
            if (!Model.IsValid)
            {
                WindowManager.ShowMessage(Model.Error);
            }
            else
            {
                Model.SaveProperties();
                this.TryOK();
            }
        }


        #endregion
    }
}
